package d2_com.itheima.regex;

import java.util.Scanner;

public class Test {
    //matches
    public static void main(String[] args) {
        //checkPhone();
        checkEmail();
    }

    public static void checkPhone() {
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("请您输入手机号：(手机|座机)");
            String phone = sc.nextLine();
            //18676769999 010-3424242424 014644535
            if (phone.matches("(1[3-9]\\d{9})|(0\\d{2,7}-?[1-9]\\d{4,19}) ")) {
                System.out.println("您输入号码格式正确~");
                break;
            } else {
                System.out.println("您输入号码格式不正确~");
            }
        }
    }

    public static void checkEmail() {
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("请您输入邮箱：");
            String eamil = sc.nextLine();
            /*
                dlei0009@163.com
                25143242@qq.com
                itheima@itcast.com.cn
            */
            if (eamil.matches("\\w{2,}@\\w{2,20}(\\.\\w{2,10}){1,2}")) {
                System.out.println("您输入邮箱格式正确~");
                break;
            } else {
                System.out.println("您输入邮箱格式不正确~");
            }
        }
    }
}
